home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gnuchess.lha / gnuchess.h < prev    next >
C/C++ Source or Header  |  1990-06-09  |  7KB  |  252 lines

  1. /*
  2.   gnuchess.h - Header file for GNU CHESS
  3.  
  4.   Revision: 1990-04-18
  5.  
  6.   Copyright (C) 1986, 1987, 1988, 1989, 1990 Free Software Foundation, Inc.
  7.  
  8.   This file is part of CHESS.
  9.  
  10.   CHESS is distributed in the hope that it will be useful, but WITHOUT ANY
  11.   WARRANTY.  No author or distributor accepts responsibility to anyone for
  12.   the consequences of using it or for whether it serves any particular
  13.   purpose or works at all, unless he says so in writing.  Refer to the CHESS
  14.   General Public License for full details.
  15.  
  16.   Everyone is granted permission to copy, modify and redistribute CHESS, but
  17.   only under the conditions described in the CHESS General Public License.
  18.   A copy of this license is supposed to have been given to you along with
  19.   CHESS so you can know your rights and responsibilities.  It should be in a
  20.   file named COPYING.  Among other things, the copyright notice and this
  21.   notice must be preserved on all copies.
  22. */
  23.  
  24. #include <stdio.h>
  25. /* <stdio.h */
  26. extern int fclose (FILE *);
  27. extern int fscanf (FILE *, const char *, ...);
  28. extern int fprintf (FILE *, const char *, ...);
  29. extern int fflush (FILE *);
  30. #define SEEK_SET 0
  31. #define SEEK_END 2
  32.  
  33. #if !defined(__STDC__) || !defined(MSDOS)
  34. #define const
  35. #endif
  36.  
  37. #ifndef __GNUC__
  38. #define inline
  39. #endif
  40.  
  41. /*
  42.   ttblsz must be a power of 2.
  43.   Setting ttblsz 0 removes the transposition tables.
  44. */
  45. #ifdef MSDOS
  46. #define ttblsz (1 << 11)
  47. #else
  48. #define ttblsz (1 << 16)
  49. #define huge
  50. #endif /* MSODS */
  51.  
  52. #define maxdepth 30
  53. #define white 0
  54. #define black 1
  55. #define neutral 2
  56. #define no_piece 0
  57. #define pawn 1
  58. #define knight 2
  59. #define bishop 3
  60. #define rook 4
  61. #define queen 5
  62. #define king 6
  63. #define bpawn 7
  64. #define pmask 0x0007
  65. #define promote 0x0008
  66. #define cstlmask 0x0010
  67. #define epmask 0x0020
  68. #define exact 0x0040
  69. #define pwnthrt 0x0080
  70. #define check 0x0100
  71. #define capture 0x0200
  72. #define draw 0x0400
  73. #define maxdepth 30
  74. #define false 0
  75. #define true 1
  76. /* #define absv(x) ((x) < 0 ? -(x) : (x)) */
  77.  
  78. struct leaf
  79. {
  80.   short f, t, score, reply;
  81.   unsigned short flags;
  82. };
  83. struct GameRec
  84. {
  85.   unsigned short gmove;
  86.   short score, depth, time, piece, color;
  87.   long nodes;
  88. };
  89. struct TimeControlRec
  90. {
  91.   short moves[2];
  92.   long clock[2];
  93. };
  94. struct BookEntry
  95. {
  96.   struct BookEntry *next;
  97.   unsigned short *mv;
  98. };
  99.  
  100. struct flags
  101. {
  102.   short mate;        /* the game is over */
  103.   short post;        /* show principle variation */
  104.   short quit;        /* quit/exit gnuchess */
  105.   short reverse;    /* reverse board display */
  106.   short bothsides;    /* computer plays both sides */
  107.   short hash;        /* enable/disable transposition table */
  108.   short force;        /* enter moves */
  109.   short easy;        /* disable thinking on opponents time */
  110.   short beep;        /* enable/disable beep */
  111.   short timeout;    /* time to make a move */
  112.   short rcptr;        /* enable/disable recapture heuristics */
  113. };
  114.  
  115. extern struct leaf Tree[2000], *root;
  116. extern short TrPnt[maxdepth];
  117. extern short board[64], color[64];
  118. extern short PieceList[2][16], PawnCnt[2][8];
  119. extern short castld[2], Mvboard[64];
  120. extern short svalue[64];
  121. extern struct flags flag;
  122. extern short opponent, computer, Awindow, Bwindow, INCscore;
  123. extern short dither, player;
  124. extern short xwndw, epsquare, contempt;
  125. extern long ResponseTime, ExtraTime, Level, et, et0, time0, ft;
  126. extern long NodeCnt, ETnodes, EvalNodes, HashCnt, HashCol;
  127. extern struct GameRec GameList[512];
  128. extern short GameCnt, Game50;
  129. extern short Sdepth, MaxSearchDepth;
  130. extern struct BookEntry *Book;
  131. extern struct TimeControlRec TimeControl;
  132. extern short TCflag, TCmoves, TCminutes, OperatorTime;
  133. extern const short otherside[3];
  134. extern const short Stboard[64];
  135. extern const short Stcolor[64];
  136. extern unsigned short hint, PrVar[maxdepth];
  137.  
  138. #define distance(a,b) distdata[a][b]
  139. #define row(a) ((a) >> 3)
  140. #define column(a) ((a) & 7)
  141. #define locn(a,b) (((a) << 3) | b)
  142. extern short distdata[64][64];
  143.  
  144. /* gnuchess.c external functions */
  145. extern void NewGame (void);
  146. /* book.c */
  147. extern int parse (FILE * fd, short unsigned int *mv, short int side);
  148. extern void GetOpenings (void);
  149. extern void OpeningBook (unsigned short int *hint);
  150. /* search.c */
  151. extern void repetition (short int *cnt);
  152. extern void SelectMove (short int side, short int iop);
  153. extern int search (short int side,
  154.            short int ply,
  155.            short int depth,
  156.            short int alpha,
  157.            short int beta,
  158.            short unsigned int *bstline,
  159.            short int *rpt);
  160. /* tran.c */
  161. #if ttblsz
  162. extern int ProbeTTable (short int side,
  163.             short int depth,
  164.             short int *alpha,
  165.             short int *beta,
  166.             short int *score);
  167. extern void PutInTTable (short int side,
  168.              short int score,
  169.              short int depth,
  170.              short int alpha,
  171.              short int beta,
  172.              short unsigned int mv);
  173. extern void ZeroTTable (void);
  174. extern void ZeroRPT (void);
  175. #ifdef HASHFILE
  176. extern int ProbeFTable (short int side,
  177.             short int depth,
  178.             short int *alpha,
  179.             short int *beta,
  180.             short int *score);
  181. extern void PutInFTable (short int side,
  182.              short int score,
  183.              short int depth,
  184.              short int alpha,
  185.              short int beta,
  186.              short unsigned int f,
  187.              short unsigned int t);
  188. #endif /* HASHFILE */
  189. #endif /* ttblsz */
  190. /* move.c */
  191. extern void Initialize_moves (void);
  192. extern void MoveList (short int side, short int ply);
  193. extern void CaptureList (short int side, short int ply);
  194. extern int castle (short int side, short int kf, short int kt, short int iop);
  195. extern void MakeMove (short int side,
  196.               struct leaf * node,
  197.               short int *tempb,
  198.               short int *tempc,
  199.               short int *tempsf,
  200.               short int *tempst,
  201.               short int *INCscore);
  202. extern void UnmakeMove (short int side,
  203.             struct leaf * node,
  204.             short int *tempb,
  205.             short int *tempc,
  206.             short int *tempsf,
  207.             short int *tempst);
  208. extern void InitializeStats (void);
  209. /* eval.c */
  210. extern int SqAtakd (short int sq, short int side);
  211. extern int evaluate (short int side,
  212.              short int ply,
  213.              short int alpha,
  214.              short int beta,
  215.              short int INCscore,
  216.              short int *slk,
  217.              short int *InChk);
  218. extern void ScoreLoneKing (short int side, short int *score);
  219. extern void ScorePosition (short int side, short int *score);
  220. extern void ExaminePosition (void);
  221. extern void UpdateWeights (void);
  222.  
  223. /* *dsp.c external functions */
  224. extern void Initialize (void);
  225. extern void InputCommand (void);
  226. extern void ExitChess (void);
  227. extern void ClrScreen (void);
  228. extern void SetTimeControl (void);
  229. extern void SelectLevel (void);
  230. extern void UpdateDisplay (short int f,
  231.                short int t,
  232.                short int flag,
  233.                short int iscastle);
  234. extern void ElapsedTime (short int iop);
  235. extern void ShowSidetomove (void);
  236. extern void SearchStartStuff (short int side);
  237. extern void ShowDepth (char ch);
  238. extern void ShowResults (short int score,
  239.              short unsigned int *bstline,
  240.              char ch);
  241. extern void algbr (short int f, short int t, short int flag);
  242. extern void OutputMove (void);
  243. extern void ShowCurrentMove (short int pnt, short int f, short int t);
  244. extern void ListGame (void);
  245. extern void ShowMessage (char *s);
  246. extern void ClrScreen (void);
  247. extern void gotoXY (short int x, short int y);
  248. extern void ClrEoln (void);
  249. extern void DrawPiece (short int sq);
  250. extern void UpdateClocks (void);
  251.  
  252.